package com.toommi.refuse.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
	//增加拦截器
	
	@Bean
    public WebMvcConfigurer getInterfaceAuthCheckInterceptor() {
        return new WebMvcConfigurer();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        // addResourceHandler是指你想在url请求的路径

        // addResourceLocations是图片存放的真实路径

        registry.addResourceHandler("/image/**").addResourceLocations("file:/opt/epage/");
        registry.addResourceHandler("/excel/**").addResourceLocations("file:/opt/excel/");
        //registry.addResourceHandler("/indeximg/**").addResourceLocations("file:C:/Users/Administrator/Desktop/index_img/");
        registry.addResourceHandler("/pageimg/**").addResourceLocations("file:/opt/khs/pageimg/");
       // registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        super.addResourceHandlers(registry);
    }
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").allowedMethods("*").allowedOrigins("*").allowedHeaders("*");
    }
//	//等部署完了，将这个方法注释一下看看。
//    public void addInterceptors(InterceptorRegistry registry){
//        registry.addInterceptor(new BootInterceptor())    //指定拦截器类
//                .addPathPatterns("/**");        //指定该类拦截的url
//    }
}
